package com.atguigu.guli.service.statistics.controller.admin;

import com.atguigu.guli.service.base.result.R;
import com.atguigu.guli.service.statistics.entity.Daily;
import com.atguigu.guli.service.statistics.service.DailyService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/admin/statistics/daily")
public class AdminDailyController {
    @Autowired
    DailyService dailyService ;
    //2.查询区间的统计数据
    @GetMapping("getStatistics/{begin}/{end}")
    public R getStatistics(@PathVariable String begin,@PathVariable String end) {
        //返回数据结构：Map<String,List<Integer>> 将查询到的数据封装为四份，存到对应集合中方便前端展示
        Map map = dailyService.getStatistics(begin,end) ;
        /*LambdaQueryWrapper<Daily> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.ge() ;
        dailyService.list(queryWrapper) ;*/
        return R.ok().data(map) ;
    }
    //1.生成指定日期统计数据 日期格式yyyyMMdd
    @PostMapping("genStatistics/{day}")
    public R genStatistics(@PathVariable String day) {
        dailyService.genStatistics(day) ;
        return R.ok() ;
    }
}
